<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});


// http://www.laravel7120.cm/api/test001
// apiFox 访问的话，会发现需要登录。
// 浏览器中登录后访问，发现自动跳转到了首页。
// 这说明，不是给浏览器访问的，而是给 ajax 访问的。
// 但是发现也不对，已经登录的用户，ajax 访问，还是报错：未认证{"message":"Unauthenticated."}、未授权401 Unauthorized。
Route::middleware('auth:api')->get('/test001', function (Request $request) {
    return $request->url();
});
